<?php
class Catalog_Form_ProductEditing extends Zend_Form
{
    public function init()
    {
        $this->setMethod('post');

        $this->setAttrib('enctype', 'multipart/form-data');
        $product = new Catalog_Model_Product();

        $definition = $product->getTable()->getColumnDefinition('title');
        $this->addElement('text', 'title', array(
            'label'      => 'Title',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('validator' => 'StringLength',
                      'options' => array(0, $definition['length']))
            )
        ));

        $definition = $product->getTable()->getColumnDefinition('short_description');
        $this->addElement('text', 'short_description', array(
            'label'      => 'Short description',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                array('validator' => 'StringLength',
                      'options' => array(0, $definition['length']))
            )
        ));

        $this->addElement('textarea', 'description', array(
            'label'      => 'Description',
            'required'   => true,
        ));

        $this->addElement('text', 'price', array(
            'label'      => 'Price',
            'required'   => true,
            'validators' => array('Float')
        ));

        $this->addElement('text', 'weight', array(
            'label'      => 'Weight',
            'required'   => true,
            'validators' => array('Float')
        ));



        $element = new Zend_Form_Element_File('foo');
        $element->setLabel('Upload an image:');
        // ensure only 1 file
        $element->addValidator('Count', false, 1);
        // limit to 100K
        $element->addValidator('Size', false, 102400);
        // only JPEG, PNG, and GIFs
        $element->addValidator('Extension', false, 'jpg,png,gif');
        //$element->
        $this->addElement($element, 'foo');


        $this->addElement('checkbox', 'active', array(
            'label'      => 'Active',
        ));
    
        $this->addElement('submit', 'submit', array(
            'label'    => 'Save',
        ));
    }
}
